package com.kk.xhr.common.pojo;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * 加班类型枚举类
 *
 * @author luokexiong
 * @version 1.0 2021/2/28
 * @since 1.0.0
 */
@Getter
@AllArgsConstructor
public enum WorkOvertimeTypeEnum {
    /** 有偿 */
    PAID((byte) 0),
    /** 无偿 */
    FREE((byte) 1),
    OTHER((byte) 2);

    private final byte value;
    private static final Map<Byte, WorkOvertimeTypeEnum> map = Arrays.stream(WorkOvertimeTypeEnum.values())
        .collect(Collectors.toMap(WorkOvertimeTypeEnum::getValue, Function.identity()));

    public static WorkOvertimeTypeEnum from(Byte from) {
        if (null == from) {
            return null;
        }
        return map.getOrDefault(from, OTHER);
    }
}
